@echo off
setlocal enabledelayedexpansion
set miss_script=0

for /L %%i in (1,1,4) do (
    if not exist step%%i.sed (
        echo step%%i.sed does not exist.
        set miss_script=1
    )
)

if not %miss_script%==0 goto miss

sed -f step1.sed %1 > %1.step1
sed -f step2.sed %1.step1 > %1.step2
sed -f step3.sed %1.step2 > %1.step3
sed -f step4.sed %1.step3 > [rf].%1

goto end

:miss
echo exiting...

:end
for /L %%i in (1,1,9) do (
    if exist %1.step%%i del %1.step%%i
)
endlocal
